package com.boxin.ims.modules.wechat.service;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.boxin.framework.base.dao.DaoHelper;
import com.boxin.framework.base.dao.OpResult;
import com.boxin.framework.base.ibatis.PagiParam;
import com.boxin.framework.base.utils.DateUtils;
import com.boxin.ims.modules.momarketing.entity.OnlineSignup;
import com.boxin.ims.modules.momarketing.entity.self.OnlineSignupConfigDetail;
import com.boxin.ims.modules.momarketing.entity.self.OnlineSignupDetail;
import com.boxin.ims.modules.sys.scheduler.SchedulerInfo;
import com.boxin.ims.modules.wechat.entity.WechatMember;
import com.boxin.ims.modules.wechat.utils.AssertUtils;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.sys.entity.Dict;

/**
 * @author Jakemanse
 * @date 2013-9-23
 * @function <p>
 *           信微模块通知 SQL Map查询操作
 *           </p>
 */
@Service
public class WechatDaoHelper {

	@Autowired
	private DaoHelper daoHelper;
	
	@Autowired
	private SqlMapClient sqlmap;

	/**
	 * @author Jakemanse
	 * @time 2013-9-23 上午11:36:55
	 * @function <p>
	 *           被动抽奖的人员范围
	 *           </p>
	 * @param params
	 *            {day,userId}
	 * @return
	 */
	public List<Map<String, Object>> queryNewMembers(Map<String, String> params) {

		return daoHelper.queryForList("com.boxin.ims.wechat.queryNewMembers",
				params);
	}

	public List<Map<String, Object>> queryQueueMembers(
			Map<String, String> params) {

		return daoHelper.queryForList("com.boxin.ims.wechat.queryQueueMembers",
				params);
	}

	/**
	 * @author Jakemanse
	 * @time 2013-10-7 下午11:48:32
	 * @function <p>
	 *           查询会员的商家抽奖中奖列表，其中不包括过期的
	 *           </p>
	 * @param member
	 * @return
	 */
	public List querySellerLotteryRecordByMember(Map<String, Object> params) {
		return daoHelper.queryForList(
				"com.boxin.ims.wechat.queryLotteryRecordByMember", params);
	}

	/**
	 * @author Jakemanse
	 * @time 2013-10-15 上午10:01:07
	 * @function <p>
	 *           用户主动抽奖
	 *           </p>
	 * @param member
	 * @return
	 */
	public List queryMineLotteryRecordByMember(Map<String, Object> params) {
		return daoHelper.queryForList(
				"com.boxin.ims.wechat.queryMineLotteryRecordByMember", params);
	}

	/**
	 * @author Jakemanse
	 * @time 2013-12-28 下午2:22:20
	 * @function <p>
	 *           查询注册礼品
	 *           </p>
	 * @param params
	 * @return
	 */
	public List queryMyRegLotteryRecordByMember(Map<String, Object> params) {
		return daoHelper.queryForList(
				"com.boxin.ims.wechat.queryMyRegLotteryRecordByMember", params);
	}
	
	
	/**
	 * @author Jakemanse
	 * @time 2014-4-22  上午10:20:46
	 * @function <p> 查询我的广告奖品 </p>
	 * @param params
	 * @return
	 */
	public List queryMyAdvertLotteryRecordByMember(Map<String, Object> params) {
		return daoHelper.queryForList(
				"com.boxin.ims.wechat.queryMyAdvertLotteryRecordByMember", params);
	}

	/**
	 * @author Jakemanse
	 * @time 2014-3-31 下午3:44:09
	 * @function <p>
	 *           查询当前人签到的 名次
	 *           </p>
	 * @param userId
	 * @return
	 */
	public String queryMemberSignupOrder(Long userId) {
		String order = (String) daoHelper.queryForObject(
				"com.boxin.ims.member.selectMemberSignOrder", userId);
		return (StringUtils.isEmpty(order)) ? "1" : order;
	}

	/**
	 * @author Jakemanse
	 * @time 2013-10-5 下午11:02:40
	 * @function <p>
	 *           是否已加入抽奖队列
	 *           </p>
	 * @param member
	 * @return
	 */
	public boolean isInLotteryQueue(WechatMember member) {
		int row = daoHelper.queryForTotalRow(
				"com.boxin.ims.wechat.queryInLotteryQueue", member);

		return (row > 0);
	}

	/**
	 * @author Jakemanse
	 * @time 2013-10-10 上午10:09:19
	 * @function <p>
	 *           </p>
	 * @param params
	 *            day month userId status awardType
	 *            (值：lottery,seckill,share,exchange)
	 * @return
	 */
	public List<Map<String, Object>> queryAwardStaticsByDay(
			Map<String, String> params) {
		return daoHelper.queryForList(
				"com.boxin.ims.wechat.statics.queryAwardStaticsByDay", params);
	}

	public List<Map<String, Object>> queryAwardStaticsByMonth(
			Map<String, String> params) {
		return daoHelper
				.queryForList(
						"com.boxin.ims.wechat.statics.queryAwardStaticsByMonth",
						params);
	}

	/**
	 * @author Jakemanse
	 * @time 2013-10-11 下午2:20:36
	 * @function <p>
	 *           获取当前会员的优惠券个数
	 *           </p>
	 * @param params
	 * @return
	 */
	public int getMyTodayCouponCount(Map<String, String> params) {
		return daoHelper.queryForTotalRow(
				"com.boxin.ims.wechat.queryCouponByOpenId", params);
	}

	/**
	 * @author Jakemanse
	 * @time 2013-10-14 下午4:01:33
	 * @function <p>
	 *           查询我的优惠券
	 *           </p>
	 * @param params
	 * @return
	 */
	public List<Map<String, Object>> queryCoupons(Map<String, String> params) {
		return daoHelper.queryForList("com.boxin.ims.wechat.queryCoupons",
				params);
	}

	public void cleanLotteryQueue(Map<String, String> params) {
		daoHelper.delete("com.boxin.ims.wechat.cleanLotteryQueue", params);
	}
	
	//清除已经中奖的用户
	public void cleanLotteryQueueByMobiles(Map<String, String> params) {
		daoHelper.delete("com.boxin.ims.wechat.cleanLotteryQueueByMobiles", params);
	}

	public List<Map<String, Object>> queryMembers(Map<String, Object> params) {
		return daoHelper.queryForList(
				"com.boxin.ims.wechat.statics.queryMembers", params);
	}
	
	
	/**
	 * @author Jakemanse
	 * @time 2014-5-1  上午9:46:49
	 * @function <p> 管理员统计各商家会员 </p>
	 * @param params
	 * @return
	 */
	public List<Map<String, Object>> queryAllMembers(Map<String, String> params) {
		return daoHelper.queryForList(
				"com.boxin.ims.wechat.statics.queryAllMembers", params);
	}

	public List<Map<String, Object>> queryLotteryData(Map<String, String> params) {
		return daoHelper.queryForList(
				"com.boxin.ims.wechat.statics.queryLotteryData", params);
	}

	/**
	 * @author Jakemanse
	 * @time 2013-10-13 下午11:28:32
	 * @function <p>
	 *           核销的统计
	 *           </p>
	 * @param params
	 * @return
	 */
	public List<Map<String, Object>> queryAllStatusLotteries(
			Map<String, String> params) {
		return daoHelper.queryForList(
				"com.boxin.ims.wechat.statics.queryAllStatusLotteries", params);
	}

	public List<Map<String, Object>> queryCategoryLotteries(
			Map<String, String> params) {
		return daoHelper.queryForList(
				"com.boxin.ims.wechat.statics.queryCategoryLotteries", params);
	}

	/**
	 * @author Jakemanse
	 * @time 2013-10-14 下午1:43:51
	 * @function <p>
	 *           查询所有核销过的奖品数量
	 *           </p>
	 * @param params
	 * @return
	 */
	public List<Map<String, Object>> queryAllUsedAwards(
			Map<String, String> params) {
		return daoHelper.queryForList(
				"com.boxin.ims.wechat.statics.queryAllUsedAwards", params);
	}

	/**
	 * @author Jakemanse
	 * @time 2013-11-14 上午12:17:33
	 * @function <p>
	 *           根据核销终端统计
	 *           </p>
	 * @param params
	 * @return
	 */
	public List<Map<String, Object>> queryAllUsedAwardsByTerminal(
			Map<String, String> params) {
		return daoHelper.queryForList(
				"com.boxin.ims.wechat.statics.queryAllUsedAwardsByTerminal",
				params);
	}

	/**
	 * @author Jakemanse
	 * @time 2013-10-14 下午1:43:51
	 * @function <p>
	 *           查询所有未核销过的奖品数量
	 *           </p>
	 * @param params
	 * @return
	 */
	public List<Map<String, Object>> queryAllUnusedAwards(
			Map<String, String> params) {
		return daoHelper.queryForList(
				"com.boxin.ims.wechat.statics.queryAllUnusedAwards", params);
	}

	/**
	 * @author Jakemanse
	 * @time 2013-10-14 下午3:09:10
	 * @function <p>
	 *           查询明细
	 *           </p>
	 * @param params
	 * @return
	 */
	public List<Map<String, Object>> queryMemberAwardsDetails(
			Map<String, String> params) {
		return daoHelper
				.queryForList(
						"com.boxin.ims.wechat.statics.queryMemberAwardsDetails",
						params);
	}

	/**
	 * @author Jakemanse
	 * @time 2013-10-16 上午9:49:24
	 * @function <p>
	 *           查询所有调度器
	 *           </p>
	 * @param params
	 * @return
	 */
	public List<Map<String, Object>> queryAllSchedulers(
			Map<String, String> params) {
		return daoHelper.queryForList(
				"com.boxin.ims.sys.scheduler.queryValidSchedulers", params);
	}

	/**
	 * @author Jakemanse
	 * @time 2013-10-16 上午9:56:14
	 * @function <p>
	 *           查询所有秒杀
	 *           </p>
	 * @param params
	 * @return
	 */
	public List<Map<String, Object>> queryAllSeckills(Map<String, String> params) {
		return daoHelper.queryForList("com.boxin.ims.wechat.queryAllSeckills",
				params);
	}

	/**
	 * @author Jakemanse
	 * @time 2013-10-16 上午10:01:56
	 * @function <p>
	 *           </p>
	 */
	public void updateSeckillNextStartTime(Map<String, String> params) {
		daoHelper.update("com.boxin.ims.wechat.updateSeckillNextStartTime",
				params);
	}

	/**
	 * @author Jakemanse
	 * @time 2013-10-16 上午11:46:15
	 * @function <p>
	 *           </p>
	 * @param params
	 * @return
	 */
	public SchedulerInfo findSchedulerInfo(Map<String, String> params) {
		SchedulerInfo schedulerInfo = (SchedulerInfo) daoHelper.queryForObject(
				"com.boxin.ims.sys.scheduler.queryScheduler", params);
		return schedulerInfo;
	}

	/**
	 * @author Jakemanse
	 * @time 2013-10-18 下午11:04:53
	 * @function <p>
	 *           抽奖过期作废
	 *           </p>
	 * @return
	 */
	public OpResult updateOvertimeLottery() {
		return daoHelper.update("com.boxin.ims.wechat.updateOvertimeLottery");
	}

	/**
	 * @author Jakemanse
	 * @time 2013-10-18 下午11:11:50
	 * @function <p>
	 *           优惠券过期作废
	 *           </p>
	 * @return
	 */
	public OpResult updateOvertimeCoupon() {
		return daoHelper.update("com.boxin.ims.wechat.updateOvertimeCoupon");
	}

	/**
	 * @author Jakemanse
	 * @time 2013-10-18 下午11:15:02
	 * @function <p>
	 *           转发有奖过期作废
	 *           </p>
	 * @return
	 */
	public OpResult updateOvertimeShare() {
		return daoHelper.update("com.boxin.ims.wechat.updateOvertimeShare");
	}

	/**
	 * @author Jakemanse
	 * @time 2013-10-18 下午11:15:16
	 * @function <p>
	 *           秒杀中奖过期作废
	 *           </p>
	 * @return
	 */
	public OpResult updateOvertimeSeckill() {
		return daoHelper.update("com.boxin.ims.wechat.updateOvertimeSeckill");
	}

	/**
	 * @author Jakemanse
	 * @time 2013-12-28 下午3:25:45
	 * @function <p>
	 *           获取预订的空闲时间
	 *           </p>
	 * @param params
	 * @return
	 */
	public List<Map<String, Object>> findFreeTimequantum(
			Map<String, String> params) {
		return daoHelper.queryForList(
				"com.boxin.ims.wechat.book.findFreeTimequantum", params);
	}

	/**
	 * @author Jakemanse
	 * @time 2013-12-30 上午12:07:07
	 * @function <p>
	 *           查询预订
	 *           </p>
	 * @param params
	 * @return
	 */
	public List<Map<String, Object>> findBookOrderRecord(
			Map<String, String> params) {
		return daoHelper.queryForList(
				"com.boxin.ims.wechat.book.findBookOrderRecord", params);
	}

	public int updateBookOrderRecord(Map<String, String> params) {
		OpResult result = daoHelper.update(
				"com.boxin.ims.wechat.book.updateBookOrderRecord", params);
		return 0;

	}

	/**
	 * @author Jakemanse
	 * @time 2014-3-12 上午11:47:49
	 * @function <p>
	 *           生成会员卡号
	 *           </p>
	 * @param userId
	 * @return
	 */
	public String generateMemberCardNumber(Long userId) {
		String number = (String) daoHelper.queryForObject(
				"com.zhixun.mobile.member.selectNewMemberNumber", userId);
		if (!StringUtils.isEmpty(number)) {
			number = number.replaceAll("MBR[0]*", "");
			int len = number.length();
			number = "MBR" + StringUtils.appendString("0", 10 - len)
					+ Integer.parseInt(number) + 1;
			return number;
		}
		return null;
	}

	/**
	 * @author Jakemanse
	 * @time 2014-3-14 上午11:45:41
	 * @function <p>
	 *           生成充值流水号
	 *           </p>
	 * @param userId
	 * @return
	 */
	public String generateRechargeSerialNumber(Long userId) {
		Long number = (Long) daoHelper.queryForObject(
				"com.boxin.ims.system.selectNextRechargeSerialNumber", userId);
		String strDate = DateUtils.formatDate(new Date(), "yyMMddHHmmss");

		String appStr = StringUtils.appendString("0",
				5 - (number.toString().length()))
				+ number;
		strDate = strDate + appStr;

		return strDate;
	}

	/**
	 * 查看我的推荐会员
	 */
	public List<Map<String, Object>> selectMyCommend(Map<String, String> params) {

		return daoHelper.queryForList(
				"com.boxin.ims.member.selectrecommendMemberByrecommendCode",
				params);
	}

	/**
	 * 根据推荐码或手机号查询会员推荐码
	 */
	public String selectmemberBymobile(Map<String, String> params) {

		WechatMember wechatMember = new WechatMember();

		String recommendCode = "";

		List<Map<String, Object>> list = daoHelper.queryForList(
				"com.boxin.ims.member.selectmemberBymobile", params);

		if (AssertUtils.notNull(list)) {
			if (list.size() > 0) {

				recommendCode = (String) list.get(0).get("recommend_code");
				;
			}

		}

		return recommendCode;
	}

	/**
	 * 用于获取会员错误数据
	 * 
	 * @author xiaoqian
	 * @return 2014-3-26上午10:35:28
	 */
	public List<Map<String, Object>> getErrorData() {
		return daoHelper.queryForList("com.boxin.ims.system.selectErrorData",
				null);
	}

	/**
	 * 通过手机号获得重复会员信息
	 * 
	 * @author xiaoqian
	 * @param params
	 * @return 2014-3-26上午11:06:00
	 */
	public List<Map<String, Object>> getMemberByMobile(
			Map<String, Object> params) {
		return daoHelper.queryForList(
				"com.boxin.ims.system.selectMemberByMobile", params);
	}

	/**
	 * 通过id删除会员信息
	 * 
	 * @author xiaoqian
	 * @param params
	 * @return 2014-3-26上午11:26:27
	 */
	public OpResult deleteMemberById(Map<String, Object> params) {
		return daoHelper
				.delete("com.boxin.ims.system.deleteMemberById", params);
	}

	/**
	 * 根据用户ID查询在线报名详细配置
	 * 
	 * @param params
	 * @return
	 * 
	 */
	public List<Map<String, Object>> selectSignupConfigDetailByUID(
			Map<String, Object> params) {

		List<Map<String, Object>> list = daoHelper.queryForList(
				"com.boxin.ims.mom.selectSignupConfigDetail", params);

		if (AssertUtils.notNull(list)) {
			if (list.size() < 1) {
				list = null;
			}
		}

		return list;
	}

	/**
	 * 根据ID集合查询用户报名详细信息
	 * 
	 * @param params
	 * @return
	 * 
	 */
	public List<OnlineSignupConfigDetail> selectSignupConfigDetailByIDList(
			Map<String, Object> params) {

		List<OnlineSignupConfigDetail> list = daoHelper.queryForList(
				"com.boxin.ims.mom.selectSignupConfigDetailByIDList", params);

		// 把list里每一个对象的detail 存成 数组 放到 types 里

		if (AssertUtils.notNull(list)) {
			if (list.size() < 1) {
				list = null;
			} else {
				OnlineSignupConfigDetail online = new OnlineSignupConfigDetail();
				List list1 = new ArrayList();
				for (int i = 0; i < list.size(); i++) {
					list1 = new ArrayList();
					online = list.get(i);
					String[] strings = online.getDetail().split("#");
					for (int j = 0; j < strings.length; j++) {
						list1.add(strings[j]);
					}
					online.setTypes(list1);

				}
			}
		}

		return list;
	}

	/**
	 * 在线报名详情
	 * 
	 */
	public void insertOnlineSignupDetail(
			List<OnlineSignupDetail> onlineSignupDetaillist) {

		Map<String, Object> map = new HashMap<String, Object>();
		for (int i = 0; i < onlineSignupDetaillist.size(); i++) {
			new HashMap<String, Object>();
			map.put("singup_id", onlineSignupDetaillist.get(i).getSignupId());
			map.put("name", onlineSignupDetaillist.get(i).getName());
			map.put("detail", onlineSignupDetaillist.get(i).getDetail());
			daoHelper.insert("com.boxin.ims.mom.insertOnlineSignupDetail", map);
		}
	}

	/**
	 * 根据ID集合查询用户报名详细信息
	 * 
	 * @param params
	 * @return
	 * 
	 */
	public List<OnlineSignup> selectSignupDetailBySingupID(
			List<OnlineSignup> detaillist) {
		Map<String, Object> map = new HashMap<String, Object>();
		OnlineSignup onlineSignup = new OnlineSignup();
		for (int i = 0; i < detaillist.size(); i++) {
			onlineSignup = detaillist.get(i);
			map.put("singup_id", onlineSignup.getId());
			List<OnlineSignupDetail> list = daoHelper.queryForList(
					"com.boxin.ims.mom.selectSignupDetailBySingupID", map);
			if (AssertUtils.notNull(list) && list.size() > 1) {
				onlineSignup.setOnlineSignupDetailList(list);
			} else {
				onlineSignup.setOnlineSignupDetailList(null);
			}

		}

		return detaillist;
	}

	/**
	 * 根据ID查询用户报名详情
	 * 
	 * @param params
	 * @return
	 * 
	 */
	public OnlineSignup selectSignupByID(String id) {
		OnlineSignup onlineSignup = new OnlineSignup();
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("id", id);
		onlineSignup = (OnlineSignup) daoHelper.queryForObject(
				"com.boxin.ims.mom.selectOnlineSignupByID", map);

		if (AssertUtils.notNull(onlineSignup)) {
			Map<String, Object> map1 = new HashMap<String, Object>();
			map1.put("singup_id", onlineSignup.getId());

			List<OnlineSignupDetail> list = daoHelper.queryForList(
					"com.boxin.ims.mom.selectSignupDetailBySingupID", map1);

			System.out.println("service" + list.size());

			if (AssertUtils.notNull(list) && list.size() > 0) {
				onlineSignup.setOnlineSignupDetailList(list);
			} else {
				onlineSignup.setOnlineSignupDetailList(null);
			}
		}

		return onlineSignup;
	}

	/**
	 * 获得活跃的用户
	 * 
	 * @author xiaoqian
	 * @param params
	 * @return 2014-4-1下午5:24:21
	 */
	public List<Map<String, Object>> selectMemberByDay(
			Map<String, Object> params) {
		return daoHelper.queryForList("com.boxin.ims.member.selectMemberByDay",
				params);
	}
	
	/**
	 * 获得签到的活跃用户
	 * 
	 * @author xiaoqian
	 * @param params
	 * @return 2014-4-1下午5:24:21
	 */
	public List<Map<String, Object>> selectSignUPMemberByDay(
			Map<String, Object> params) {
		return daoHelper.queryForList("com.boxin.ims.member.selectSignUPMemberByDay",
				params);
	}
	
	/**
	 * 获得平台活跃用户
	 * 
	 * @author xiaoqian
	 * @param params
	 * @return 2014-4-1下午5:24:21
	 */
	public List<Map<String, Object>> selectPlatformByDay(
			Map<String, Object> params) {
		return daoHelper.queryForList("com.boxin.ims.member.selectPlatformByDay",
				params);
	}
	
	
	/**
	 * 得到优惠券商家类型
	 * 
	 * @param params
	 * @return 2014-4-1下午5:24:21
	 */
	public List<Dict> selectDictByType() {
		return daoHelper.queryForList("com.boxin.ims.system.selectDictByType",
				null);

	}

	/**
	 * 根据商家ID查询优惠卷配置商家类型
	 * 
	 * @param params
	 * @return 2014-4-1下午5:24:21
	 */
	public List<Map<String, Object>> selectCouponConfigByUserID(
			Map<String, Object> params) {
		return daoHelper.queryForList(
				"com.zhixun.mobile.member.selectCouponConfigByUserID", params);

	}

	public Object selectMemberIdByQRcodeId(Long id) {
		return daoHelper.queryForObject(
				"com.boxin.ims.wechat.selectMemberIdByQRcodeId", id);
	}

	/**
	 * 修改仓库商品表分类名称
	 */
	public void updateCategoryName(Map<String, Object> params) {

		daoHelper.update("com.boxin.ims.cargo.updateCategoryName", params);

	}

	/**
	 * 修改仓库商品表单位名称
	 */
	public void updateUnitName(Map<String, Object> params) {

		daoHelper.update("com.boxin.ims.cargo.updateUnitName", params);

	}

	/**
	 * 修改仓库商品表仓库名称
	 */
	public void updateWarehouseName(Map<String, Object> params) {

		daoHelper.update("com.boxin.ims.cargo.updateWarehouseName", params);

	}

	/**
	 * 根据用户ID和商品批次号查询商品
	 */
	public List<Map<String, Object>> selectCargoByUidAndBatchNumber(
			Map<String, Object> params) {
		return daoHelper.queryForList(
				"com.boxin.ims.cargo.selectCargoByUidAndBatchNumber", params);

	}

	/**
	 * 根据用户ID和商品批次号查询商品
	 */
	public List<Map<String, Object>> selectCargoByUid(Map<String, Object> params) {

		return daoHelper.queryForList(
				"com.boxin.ims.cargo.selectCargoByUid", params);

	}
	
	
	
	/**
	 * @author Jakemanse
	 * @time 2013-10-7 下午11:48:32
	 * @function <p>
	 *          删除wp_option 中的信息
	 * @param member
	 * @return
	 */
	public OpResult deleteOptionByquestionId(Map<String, Object> params) {
		return daoHelper.delete(	"com.boxin.ims.member.deleteOptionByquestionId", params);
	}
	
	
	
	/**
	 * 通过QuestionId查找
	 *@author xiaoqian
	 * @param params
	 * @return
	 * 2014-5-12上午11:11:22
	 */
	public  List<Map<String, Object>> selectquestionnaireReplyByQuestionId(Map<String, Object> params) {
		return daoHelper.queryForList("com.boxin.ims.member.selectquestionnaireReplyByQuestionId", params);
	}
	
	
	/**
	 * 查找LotteryRecourd表中中奖的信息
	 *@author xiaoqian
	 * @param params
	 * @return
	 * 2014-5-12上午11:11:22
	 */
	public  List<Map<String, Object>> queryLotteryRecordBYSourceType(Map<String, Object> params) {
		return daoHelper.queryForList("com.boxin.ims.wechat.statics.queryLotteryRecordBYSourceType", params);
	}
	
	
	/**
	 * 查找share表中中奖的信息
	 *@author xiaoqian
	 * @param params
	 * @return
	 * 2014-5-12上午11:11:22
	 */
	public  List<Map<String, Object>> queryShareBYWin(Map<String, Object> params) {
		return daoHelper.queryForList("com.boxin.ims.wechat.statics.queryShareBYWin", params);
	}
	
	
	/**
	 * 查找sckillGainer表中中奖的信息
	 *@author xiaoqian
	 * @param params
	 * @return
	 * 2014-5-12上午11:11:22
	 */
	public  List<Map<String, Object>> querySeckillGainer(Map<String, Object> params) {
		return daoHelper.queryForList("com.boxin.ims.wechat.statics.querySeckillGainer", params);
	}
	
	/**
	 * 查找Coupon表中中奖的信息
	 *@author xiaoqian
	 * @param params
	 * @return
	 * 2014-5-12上午11:11:22
	 */
	public  List<Map<String, Object>> queryCoupon(Map<String, Object> params) {
		return daoHelper.queryForList("com.boxin.ims.wechat.statics.queryCoupon", params);
	}

	/**
	 * 根据微购物查询核销统计
	 *@author xiaoqian
	 * @param params
	 * @return
	 * 2014-9-26下午2:03:33
	 */
	public  List<Map<String, Object>> queryAllUsedAwardsByShopping(Map<String, Object> params) {
		return daoHelper.queryForList("com.boxin.ims.wechat.statics.queryAllUsedAwardsByShopping", params);
	}
	
	/**
	 * 查找ExchangeRecord表中中奖的信息
	 *@author xiaoqian
	 * @param params
	 * @return
	 * 2014-5-12上午11:11:22
	 */
	public  List<Map<String, Object>> queryExchangeRecord(Map<String, Object> params) {
		return daoHelper.queryForList("com.boxin.ims.wechat.statics.queryExchangeRecord", params);
	}
	
	
	//清除wp_member_lottery 当日的记录
		public void cleanMemberLotteryByToday(Map<String, Object> params) {
			daoHelper.delete("com.boxin.ims.wechat.statics.deleteMemberLottery", params);
		}
		
		
		/**
		 * 查找LotteryRecourd表中中奖的信息
		 *@author xiaoqian
		 * @param params
		 * @return
		 * 2014-5-12上午11:11:22
		 */
		public  List<Map<String, Object>> getQuestionType3ById(Map<String, Object> params) {
			return daoHelper.queryForList("com.boxin.ims.member.getQuestionType3ById", params);
		}
		
		
		public  List<Map<String, Object>> getMember() {
			return daoHelper.queryForList("com.boxin.ims.member.getMember", null);
		}
		
		public  List<Map<String, Object>> selectProjectMenu() {
			return daoHelper.queryForList("com.boxin.ims.mom.selectProjectMenu", null);
		}
		
		/**
		 * 清除微购物中的菜单通过user_id   ,pageTemplateId
		 *@author xiaoqian
		 * @param params
		 * @return
		 * 2014-5-12上午11:11:22
		 */
		public void clearMicroSiteMenu(String user_id, String template_Id){
			Map<String, Object> params = new HashMap<String,Object>();
			params.put("user_id",user_id);
			params.put("template_Id", template_Id);
			daoHelper.update("com.boxin.ims.wechat.clearMicroSiteMenu", params);
		}
		
		
		
		/**
		 * 跟新页面留言状态
		 *@author xiaoqian
		 * @param params
		 * @return
		 * 2014-5-12上午11:11:22
		 */
		public void updateGuestBookStatus(String userId, String wechatId){
			Map<String, Object> params = new HashMap<String,Object>();
			params.put("user_id",userId);
			params.put("open_id", wechatId);
			daoHelper.update("com.boxin.ims.wechat.updateGuestBookStatus", params);
		}
		
		/**
		 * 俏皮话
		 *@author xiaoqian
		 * @return
		 * 2014-7-9上午9:25:34
		 */
		public   List<Map<String, Object>> getWitticismByOne(Map<String, Object> params) {
			return  daoHelper.queryForList("com.boxin.ims.wechat.getWitticismByOne", params);
		}
	
		
		
		
		
		/**
		 * 查询微购物中试用   的批次
		 *@author xiaoqian
		 * @return
		 * 2014-7-9上午9:25:34
		 */
		public   List<Map<String, Object>> getShoppingTryMember() {
			return  daoHelper.queryForList("com.boxin.ims.wechat.statics.queryShoppingTryMember", null);
		}
		
		
		/**
		 * 获取  平台信息
		 *@author xiaoqian
		 * @return
		 * 2014-10-15下午6:16:06
		 */
		public   List<Map<String, Object>> getWechatMessageSource(Map<String, Object> params) {
			return  daoHelper.queryForList("com.boxin.ims.bi.queryWechatMessageSource", params);
		}
		
		/**
		 * 获取平台信息数量
		 *@author xiaoqian
		 * @param params
		 * @return
		 * 2014-10-15下午7:19:25
		 */
		public   List<Map<String, Object>> getWechatMessageSourceCount(Map<String, Object> params) {
			return  daoHelper.queryForList("com.boxin.ims.bi.queryWechatMessageSourceCount", params);
		}
		
		
		
		/**
		 * 
		 *@author xiaoqian
		 * @param params
		 * @return
		 * 2014-10-28下午4:42:56
		 */
		public  List<Map<String, Object>> queryMemberLotteryByDay(Map<String, Object> params) {
			return daoHelper.queryForList("com.boxin.ims.wechat.statics.queryMemberLotteryByDay", params);
		}
		
		
		
		/**
		 * 查找会员积分
		 * @author zhangshanshan
		 * @param params
		 * @return
		 */
		public List<Map<String, Object>> findMemberScoreByMemberId(Map<String, Object> params) {
			return daoHelper.queryForList("com.boxin.ims.wechat.book.selectMemberScoreByMemberId", params);
		}
		
		/**
		 * 查找会员的经验值
		 * @author zhangshanshan
		 * @param params
		 * @return
		 */
		public List<Map<String, Object>> findMemberExperienceByMemberId(Map<String, Object> params) {
			return daoHelper.queryForList("com.boxin.ims.wechat.book.selectMemberExperienceByMemberId", params);
		}

		
		
		
		
		/**
		 * ziyang
		 * 查询会员返利
		 * @param params
		 * @return
		 */
		public List<Map<String, Object>> queryMemberCashBack(Map<String, Object> params)	{
			return daoHelper.queryForList("com.zhixun.mobile.member.queryMemberCashBack", params);
		}
		/**
		 * ziyang
		 * 查询会员佣金
		 * @param params
		 * @return
		 */
		public List<Map<String, Object>> queryMemberMoney(Map<String, Object> params){
			return daoHelper.queryForList("com.zhixun.mobile.member.queryMemberMoney", params);
			
		}
		
		/** 三级推广：根据推荐码查找被推荐人 */
		public List<Map<String, String>> findMemberByParentCode(Map<String, Object> params){
			return daoHelper.queryForList("com.boxin.ims.member.findMemberByParentCode",params);
		}
		/** 三级推广：根据积分倒序排列 */
		public List<Map<String, String>> findMemberByscore(Map<String, Object> params){
			return daoHelper.queryForList("com.boxin.ims.member.findMemberByscore",params);
		}
		/** 三级推广：根据推广积分倒序排列 */
		public List<Map<String, String>> findMemberByRecommendScore(Map<String, Object> params){
			return daoHelper.queryForList("com.boxin.ims.member.findMemberByRecommendScore",params);
		}
		/** 三级推广：查找积分数量 */
		public Integer selectMemberScoreCount(Map<String, Object> map) {
			Integer integer = (Integer) daoHelper.queryForObject("com.boxin.ims.member.selectMemberScoreCount",map);
			return integer;
		}
		/** 三级推广：查找积分分页  */
		public List<Map<String, String>> selectMemberScore(Map<String, Object> params){
			return daoHelper.queryForList("com.boxin.ims.member.selectMemberScore",params);
		}
		
		/** 三级推广：查找积分排行  */
		public List<Map<String, Object>> findScoreRankList(Map<String, Object> params){
			return daoHelper.queryForList("com.boxin.ims.member.findScoreRankList",params);
		}
		
		/** 三级推广：活动结束后将积分请零  */
		public void updateMemberRecommendScore(Map<String, Object> params){
			daoHelper.update("com.boxin.ims.member.updateMemberRecommendScore",params);
		}
		
		/** 三级推广：查找积分兑换奖品总数量  */
		public Integer selectExchangeRecordCount(Map<String, Object> map) {
			Integer integer = (Integer) daoHelper.queryForObject("com.boxin.ims.member.selectExchangeRecordCount",map);
			return integer;
		}
		
		/** 三级推广：查找会员兑换奖品记录  */
		public List<Map<String, Object>> selectmyGoodsBymemberId(Map<String, Object> params){
			return daoHelper.queryForList("com.boxin.ims.member.selectmyGoodsBymemberId",params);
		}
		
		/** 查找奖品  */
		public List<Map<String, String>> findLottery(Map<String, Object> params){
			return daoHelper.queryForList("com.boxin.ims.member.findLottery",params);
		}
		
		
		//查找兑换记录
		public List<Map<String, String>> findExchangeRecord(Map<String, Object> params){
			return daoHelper.queryForList("com.zhixun.mobile.member.findExchangeRecord",params);
		}
		//查找兑换记录数量
		public Integer findExchangeRecordCount(Map<String, Object> map) {
			Integer integer = (Integer) daoHelper.queryForObject("com.zhixun.mobile.member.findExchangeRecordCount",map);
			return integer;
		}

		/**
		 * 人气大比拼获取排行榜
		 *@author xiaoqian
		 * @param params
		 * @return
		 * 2015-1-10下午1:13:48
		 */
		public  List<Map<String, Object>> queryPaiAccessCount(Map<String, Object> params) {
			return daoHelper.queryForList("com.zhixun.mobile.site.queryPaiAccessCount", params);
		}
		
}
